<template>
	<!-- 二维码 -->
	<view class="qr-box">
		<image :src="urlInfo"></image>
	</view>
</template>

<script>
	import uQRCode from '@/utils/uqrcode.js' //引入uqrcode.js
	import { getPreviewUrl } from "@/utils/common"
	export default {
		data() {
			return {
				urlInfo: '',
			}
		},
		onLoad(options) {
			if (!!options.qrCodePath) {
				this.code = options.qrCodePath;
				this.urlInfo = getPreviewUrl(this.code)
				// this.qrFun()
			}
		},
		methods: {
			//**生成二维码**//
			qrFun: function (text) {
				this.qrShow = true
				uQRCode.make({
					canvasId: 'qrcode',
					componentInstance: this,
					text: `${this.code}`,
					size: 300,
					margin: 0,
					backgroundColor: '#ffffff',
					foregroundColor: '#000000',
					fileType: 'jpg',
					errorCorrectLevel: uQRCode.errorCorrectLevel.H,
					success: res => { }
				})
			}
		}
	}
</script>

<style>
	.qr-box {
		width: 750rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		margin-top: 40rpx;
	}
</style>